package com.demo.di.factory_bean;

import java.security.MessageDigest;

/**
 * 描述：
 *
 * @author lida
 * @time 2019/10/14 16:47
 */
class MessageDigester {
	private MessageDigest digest1;
	private MessageDigest digest2;

	public void setDigest1(MessageDigest digest1){
		this.digest1 = digest1;
	}

	public void setDigest2(MessageDigest digest2){
		this.digest2 = digest2;
	}

	public void digest(String msg){
		System.out.println("Using digest1");
		digest(msg, digest1);

		System.out.println("Using digest2");
		digest(msg, digest2);
	}

	public void digest(String msg, MessageDigest messageDigest){
		System.out.println("Using alogrithm: " + messageDigest.getAlgorithm());
		messageDigest.reset();
		byte[] bytes = msg.getBytes();
		byte[] out = messageDigest.digest(bytes);
		System.out.println(out);
	}
}
